/**
 * @author guocailee
 */
// import types from '../types.js'
import types from '../types.js'
import * as infoServices from 'src/api/info'

export const getUserInfo = (store) => {
  return infoServices.queryUserInfo().then(data => {
    store.dispatch(types.info.UPDATE_BASEINFO, data)
  })
}

export const updateBaseInfo = (store, baseInfo) => {
  return infoServices.updateUserInfo(baseInfo)
    .then(data => store.dispatch(types.info.UPDATE_BASEINFO, baseInfo))
}

export const updateAvatar = (store, params) => {
  return infoServices.chgUserPortrait(params.fileName)
    .then(data => store.dispatch(types.info.UPDATE_AVATAR, params.imageUrl))
}
